<template>
  <swiper ref="mySwiper" :options="swiperOptions">
    <template v-for="(item, i) in data">
      <swiper-slide :key="i">
        <img :src="item.img" alt="" />
      </swiper-slide>
    </template>
    <div class="swiper-pagination" slot="pagination"></div>
  </swiper>
</template>

<script>
import { Swiper, SwiperSlide, directive } from "vue-awesome-swiper";
import "swiper/css/swiper.css";

export default {
  props: {
    data: {
      type: Array,
      required: true,
    },
  },
  components: {
    Swiper,
    SwiperSlide,
  },
  directives: {
    swiper: directive,
  },
  data() {
    return {
      swiperOptions: {
        pagination: {
          el: ".swiper-pagination",
          clickable: true,
        },
        // Some Swiper option/callback...
      },
    };
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.$swiper;
    },
  },
  mounted() {
    // console.log("Current Swiper instance object", this.swiper);
    // this.swiper.slideTo(3, 1000, false);
  },
};
</script>

<style lang="scss" scoped>
.swiper-container {
  height: 100%;

  img {
    height: 100%;
  }

  ::v-deep .swiper-pagination-bullet {
    width: 12px;
    height: 12px;
    background: #ffffff;
    opacity: 0.7;
    border-radius: 50%;
    transition: width 0.3s ease-in-out;
  }
  ::v-deep .swiper-pagination-bullet-active {
    width: 39px;
    height: 12px;
    background: #ffffff;
    border-radius: 6px;
  }
}
</style>
